package com.hzhq.contract.repo;

import com.hzhq.contract.bean.entity.Contract;
import com.hzhq.contract.bean.entity.ContractType;
import com.hzhq.contract.bean.entity.Depart;
import com.hzhq.contract.bean.entity.User;
import org.bson.types.ObjectId;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;

import java.util.List;
import java.util.Optional;

/**
 * @author hzhq
 * @create 2021/4/8 11:36 下午
 * @email hzhq1255@163.com
 */
public interface ContractRepository extends MongoRepository<Contract, ObjectId> {
    
    
    Optional<Contract> findByContractIdAndDeleted(ObjectId id, Integer deleted);
    
    Optional<Contract> findByContractNameAndDeleted(String name, Integer deleted);
    
    Page<Contract> findAllByDeleted(Integer deleted, Pageable pageable);
    
    Page<Contract> findAllByDepartInAndDeleted(List<Depart> departList, Integer deleted, Pageable pageable);
    
    Page<Contract> findAllByContractTypeAndDeleted(ContractType type, Integer deleted, Pageable pageable);
    
    Page<Contract> findAllByPassedAndDeleted(Integer passed, Integer deleted, Pageable pageable);
    
    Page<Contract> findAllByEditedAndDeleted(Integer edited, Integer deleted, Pageable pageable);
    
    Page<Contract> findAllByCreateUserAndDeleted(User user, Integer deleted, Pageable pageable);
    
    Page<Contract> findAllByApprovalPersonAndDeleted(User user, Integer deleted, Pageable pageable);
    
    Page<Contract> findAllByContractNameLikeAndDeleted(String name, Integer deleted, Pageable pageable);

    List<Contract> findAllByContractIdInAndDeleted(List<ObjectId> ids, Integer deleted);

}
